package com.chance.cc.crawler.development.bootstrap.weibo.hotList;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.downloader.HttpConfig;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

/**
 * @ClassName weibo
 * @Description TODO
 * @Author songding
 * @Date 2021/10/8 15:21
 * @Version 1.0
 **/
public class WeiboHotListStart {
    private static final String domain = "weibo";
    private static final String site = "hotList";
    public static void main(String[] args) {
        limit();
    }

    public static void limit(){
        String url = "https://v6.bang.weibo.com/newczv/1043?date=%s&disable_gesture_back=1&choose_flag=1&period_type=week#";
        String time = "20210920";
        url = String.format(url,time);
        CrawlerRequestRecord requestRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(domain)
                .httpUrl(url)
                .httpConfig(HttpConfig.me(domain))
                .releaseTime(System.currentTimeMillis())
                .filter(CrawlerEnum.CrawlerRecordFilter.dateRange)
                .resultLabelTag(CrawlerEnum.CrawlerDataType.article)
                .resultLabelTag(CrawlerEnum.CrawlerDataType.interaction)
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(24*7,null))
                .build();
        requestRecord.tagsCreator().bizTags().addCustomKV("time",time);
        requestRecord.tagsCreator().bizTags().addCustomKV("type","week");
        requestRecord.tagsCreator().bizTags().addDomain(domain);
        requestRecord.tagsCreator().bizTags().addSite(site);

        DevCrawlerController.builder()
                .triggerInfo(domain,domain,System.currentTimeMillis(),domain)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))
                .consoleResultPipeline()
                .fileResultPipeline("F:\\chance_log\\weibo\\data.log",true)
                .requestRecord(requestRecord)
                //.supportRecord(keywordRecord)
                .build("com.chance.cc.crawler.development.scripts.weibo")
                .start();
    }
}
